package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter@Setter
public class Goods extends BaseDomain{
    public static final Integer STATE_OUT = 0; //下架
    public static final Integer STATE_ADD = 1; //上架

    private String name; //商品名称

    private Long goodStyleId;//类别id

    private String goodStyleName;//类别名称

    private Integer repertory;//库存

    private String coverUrl;//图片

    private Integer price = 0;//价格

    private Integer state = STATE_ADD;//状态

    public String getStateName(){
        String msg = "上架";
        if (state == STATE_OUT){
            msg = "下架";
        }
        return msg;
    }

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("goodStyleId", goodStyleId);
        map.put("goodStyleName", goodStyleName);
        map.put("repertory", repertory);
        map.put("coverUrl", coverUrl);
        map.put("price", price);
        map.put("state" , state);
        return JSONUtil.toJSONString(map);
    }

}